14, av Milton NANCY 83.40.36.80 ----------------- Club dev. de NANCY 1993-1994
This script saves AppleScript data to a disk file. This is faster and more useful than passing data indirectly via an editor. In addition, the type and creator of the file can be parameterized. This allows you to save the results of a script and more.
The replacement option, if activated (yes), allows you to completely replace the file; if not the string is written at the end of the specified file (mode append).
In this case, the erase option controls the file deletion. "erase true" or "with erase" effectively deletes the file; "without erase" does not delete, but overwrites the data; this is useful for completing or replacing the data fork of an application, using the "replacing yes without erase" option.
Note: "replacing no" adds the data to the end of the file.
read data
The read command allows you to extract the variables saved in a file. This read function applies to the data fork of a file. It is possible to quickly learn the contents of the data fork of an application. The read lmit is 32,000 bytes here; the results window seems to be limited to 20,000 bytes.
For saving and reading data, you should use data type "TEXT"; this type works best. The script is presented in English but the 'aet' resources for the French script are installed and valid, although not tested.
Formulation :
save data data -- data or variable object to store
in alias -- path to file to store in
[replacing yes/no] -- replace the file (defaut no)
[type type class] -- type of file (default "TEXT")
[creator 'sign'] -- creator of file
(default "ttst") teachtext
[erase boolean] -- with | without erase
Result: integer -- error returned from storing
(if any)
read data of (alias) -- read a document
read data of file "abc" -- idem
exp:
set p to 45
save data p in file "LCII:test" type "TEXT" creator "abcd" replacing yes
save data p in file "LCII:file"
set x to find document name "Save-osax.c"
read data of x
Writing in the data fork of an application
set p to "data from the application"
save data p in file "LCII:application" replacing yes without erase
The "without erase" option avoides deleting the application, of course!! The "replacing no" option as well which appends data to the end.
Have fun!
Contact PAUTEX jf
14, av Milton 54000 nancy >>>>>>>> e-mail pautex@lpmi.u-nancy.fr <<<<<<<<<